package com.errol.batchprocessor.employeeaddition.advisorimpl.common.payload;

import com.renjia.entity.*;
import com.renjia.enums.EmployeeRegisterSourceEnum;
import com.renjia.service.generic.middleware.batchprocessor.payload.AbstractBatchPayload;
import com.renjia.service.generic.support.customer.bo.ProtocolAndSignatureBO;
import com.renjia.service.module.employeeaddition.advisorimpl.EmployeeAdvisorTypeEnum;
import lombok.Getter;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 人员导入批处理业务 批次数据抽象类
 *
 * @author zhang xiao bin
 * @version v1.0
 * @date 2021/02/22
 * @since v5.0.5
 **/
@Getter
public abstract class AbstractEmployeeBatchPayload<BE, SE> extends AbstractBatchPayload<CoreEmployeeImportBatch, EmployeeAdvisorTypeEnum, BE, SE> {

    private final EmployeeRegisterSourceEnum employeeRegisterSource;
    private final CoreCustomerChannelMerchant coreCustomerChannelMerchant;
    private final CoreUser coreUser;

    private CoreChannelMerchant coreChannelMerchant;
    private CoreCustomer coreCustomer;

    private final Map<String, SE> documentMap;
    private ProtocolAndSignatureBO protocolAndSignatureBO;
    private boolean needCheckThreeElement;
    /**
     * 三要素验证失败时进入审核：编辑接单导入失败记录满一定次数，失败时进入待审核
     */
    private boolean shallForceAuthorized;
    /**
     * 是否允许无视手机号重复（不拦截，不保存手机号）：默认不允许
     */
    private boolean ignoreMobileRepeated;

    public AbstractEmployeeBatchPayload(@NonNull String batchNo, @NonNull CoreEmployeeImportBatch importBatch, @Nullable BE batchEntity, @NonNull List<SE> singleEntityList,
                                        @NonNull EmployeeAdvisorTypeEnum employeeAdvisorType, @NonNull EmployeeRegisterSourceEnum employeeRegisterSource,
                                        @NonNull CoreCustomerChannelMerchant coreCustomerChannelMerchant, @NonNull CoreUser coreUser,
                                        @Nullable CoreChannelMerchant coreChannelMerchant, @Nullable CoreCustomer coreCustomer) {
        super(batchNo, employeeAdvisorType, importBatch, batchEntity, singleEntityList);
        this.employeeRegisterSource = employeeRegisterSource;
        this.coreCustomerChannelMerchant = coreCustomerChannelMerchant;
        this.coreUser = coreUser;
        this.coreChannelMerchant = coreChannelMerchant;
        this.coreCustomer = coreCustomer;
        this.documentMap = new HashMap<>(singleEntityList.size());
        this.needCheckThreeElement = true;
        this.shallForceAuthorized = false;
        this.ignoreMobileRepeated = false;
    }

    public void setCoreChannelMerchant(CoreChannelMerchant coreChannelMerchant) {
        if (this.coreChannelMerchant == null) {
            this.coreChannelMerchant = coreChannelMerchant;
        }
    }

    public void setCoreCustomer(CoreCustomer coreCustomer) {
        if (this.coreCustomer == null) {
            this.coreCustomer = coreCustomer;
        }
    }

    public void setProtocolAndSignatureBO(ProtocolAndSignatureBO protocolAndSignatureBO) {
        this.protocolAndSignatureBO = protocolAndSignatureBO;
    }

    public void setNeedCheckThreeElement(boolean needCheckThreeElement) {
        this.needCheckThreeElement = needCheckThreeElement;
    }

    public void setShallForceAuthorized(boolean shallForceAuthorized) {
        this.shallForceAuthorized = shallForceAuthorized;
    }

    public void setIgnoreMobileRepeated(boolean ignoreMobileRepeated) {
        this.ignoreMobileRepeated = ignoreMobileRepeated;
    }
}
